// JavaScript Document
function update_menu(req)
{
   if(req.status == 200)
   {
      if(req.responseText=="")
         $("menu").innerHTML="<div style='padding:10px;'>无可访问菜单</div>";
      else
      {
         $("menu").innerHTML=req.responseText;
         if(sub_menu == 2) c('mMENU_SHORTCUT');
      }
   }
   else
   {
      $("menu").innerHTML="<div style='padding:10px;'>错误："+req.status+"</div>";
   }
}
 
var cur_id="",cur_expand="";
var flag=0,sflag=0;
 
//-------- 菜单点击事件 -------
function c(id)
{
  var targetid,targetelement;
  var strbuf;
 
  var el=$(id);
  if(!el)
     return;
  //-------- 如果点击了展开或收缩按钮---------
  targetid=el.id+"d";
  targetelement=$(targetid);
  var expandUL=$(cur_expand+"d");
  var expandLink=$(cur_expand);
 
  if (targetelement.style.display=="none")
  {
     if(expandUL && expandLink && el.id.substr(0,1)=="m")
     {
        expandLink.className="";
        expandUL.style.display='none';
     }
     if(el.id.substr(0,1)=="m")
        cur_expand=el.id;
     el.className="active";
     targetelement.style.display='';
 
     menu_flag=0;
     //$("expand_link").src="images/green_minus.gif";
  }
  else
  {
     el.className="";
     targetelement.style.display="none";
 
     menu_flag=1;
     //$("expand_link").src="images/green_plus.gif";
     var links=document.getElementsByTagName("A");
     for (i=0; i<links.length; i++)
     {
       el=links[i];
       if(el.parentNode.className.toUpperCase()=="L1" && el.className=="active" && el.id.substr(0,1)=="m")
       {
          menu_flag=0;
         // $("expand_link").src="images/green_minus.gif";
          break;
       }
     }
  }
}
//-------- 打开网址 -------
var $ = function(id) {return document.getElementById(id);};
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
function MouseOverBtn(){event.srcElement.className+="Hover";}
function MouseOutBtn() {event.srcElement.className=event.srcElement.className.substr(0,event.srcElement.className.indexOf("Hover"));}
function CorrectButton()
{
   var inputs=document.getElementsByTagName("INPUT");
   for(var i=0; i<inputs.length; i++)
   {
      var el = inputs[i];
      var elType = el.type.toLowerCase();
      var elClass = el.className.toLowerCase();
      var elLength = Math.ceil(el.value.replace(/[^\x00-\xff]/g,"**").length/2);
      if(elType!="button" && elType!="submit" && elType!="reset" || elClass!="bigbutton"&&elClass!="smallbutton")
         continue;
      
      if(elLength<=3)
         el.className+="A";
      else if(elLength==4)
         el.className+="B";
      else if(elLength>=5 && elLength<=7)
         el.className+="C";
      else if(elLength>=8 && elLength<=11)
         el.className+="D";
      else
         el.className+="E";
      
      if(is_ie)
      {
         el.attachEvent("onmouseover", MouseOverBtn);
         el.attachEvent("onmouseout",  MouseOutBtn);
      }
   }
}
if(is_ie)
   window.attachEvent("onload", CorrectButton);
else
   window.addEventListener("load", CorrectButton,false);